<template>
  <div id="change_phone_view">

    <header class="mui-bar mui-bar-nav">
      <a class=" mui-icon  mui-pull-left  arr_left" @tap="open_change_phone_view(false)">
      </a>
      <h1 class="mui-title">验证旧手机号</h1>

    </header>
    <div class="my_content mui-content">
      <div class="mu_login-all" id="my_login">
        <ul class="my_login">
          <li class="my_login_li">
            <span>手机号</span>
            <input type="text" disabled="disabled" :value="$store.state.account.user_info.phone"/>
          </li>
          <li class="my_login_li">
            <span>验证码</span>
            <input type="text" v-model="code_msg" placeholder="请输入验证码"/>
            <input class="login-num-btn" @tap="get_code_msg" id="get_msg_btn" name="color" type="button" value="获取验证码"/>

          </li>
        </ul>
        <div class="my_butn" @tap="next_step">
          <button>下一步</button>
        </div>
      </div>
    </div>
    <transition enter-active-class="animated slideInRight" leave-active-class="animated slideOutRight">
      <ChangePhone2 v-if="$store.state.account.show_change_phone_view2"></ChangePhone2>
    </transition>
  </div>

</template>

<script>
  import phone_msg_ajax from '../../ajax/phone_msg_ajax'
  import ChangePhone2 from './ChangePhone2'

  export default {
    name: "change_phone",
    data() {
      return {
        code_msg: '',
        code_server: '',
        show_next_step:false
      }
    },
    methods: {

      get_code_msg() {
        let el = document.getElementById("get_msg_btn");
        let phone = this.$store.state.account.user_info.phone
        phone_msg_ajax.get_code_msg(el, phone, res => {
          console.log("获取短信验证码成功-->" + res)
          this.code_server =res;
        })
      },
      next_step() {
        if (!this.code_msg) {
          mui.toast("请填写验证码")
        } else {
          if (this.code_msg == this.code_server) {
            // 打开下一步
            this.$store.commit("open_change_phone_view2",true)
            this.show_next_step=true
          } else {
            mui.toast("验证码错误")
          }
        }
      },
      open_change_phone_view(tf){
        this.$store.commit("open_change_phone_view",tf)
      }
    },
    components: {
      ChangePhone2
    }
  }
</script>

<style scoped lang="less">
  html,
  body {
    background-color: #f6f6f6;
    min-height: 100vh;
    font-size: 0.373rem/0.625;
  }

  #change_phone_view {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 10001;
    background-color: #fff;
  }

  ul,
  ol {
    list-style: none;
  }

  body input[type='text'],
  ul,
  li {
    padding: 0;
    margin: 0;
  }

  .clear {
    clear: both;
    height: 0;
    font-size: 0;
    line-height: 0;
    visibility: hidden;
    overflow: hidden;
  }

  /*顶部*/

  .my_login_li {
    background: #fff;
    padding: 0 0.373rem/0.625;
    display: flex;
    line-height: 1.333rem/0.625;
    border-bottom: 1px solid #e2e2e2;
    justify-content: center;
    align-items: center;
  }

  .my_login_li span {
    padding-left: 0.373rem/0.625;
    width: 7.8rem;
    text-align: left;
  }

  .my_login_li input {
    border: 0;
    line-height: 1.333rem/0.625;
    height: 1.333rem/0.625;
    color: #888888;
  }

  .my_login_li .login-num-btn {
    width: 2.893rem/0.625;
    border: 1px #888888 solid;
    height: 0.786rem/0.625;
    line-height: 0.786rem/0.625;
    padding: 0 0.2rem/0.625;
  }

  .my_content {
    background: #f6f6f6;
  }

  .my_login {
    padding-top: 0.253rem/0.625;
  }

  .my_content button {
    background: url(../../assets/images/my_buttom.png) no-repeat;
    color: #FFFFFF;
    line-height: 1.266rem/0.625;
    height: 1.266rem/0.625;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
    background-size: 100% 100%;
    border: 0;
  }

  .my_butn {
    margin: 1.093rem/0.625 0.373rem/0.625;
  }

  .my_login_li .classcolor {
    background: #000;
    width: 2.893rem/0.625;
    border: 1px #888888 solid;
    height: 0.786rem/0.625;
    line-height: 0.786rem/0.625;
    padding: 0 0.2rem/0.625;
  }

  .my_login_li input[type='text'] {
    font-size: 0.373rem/0.625;
  }

  #phone {
    color: #000000 !important;
  }
</style>
